<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="bootstrap-4.4.1-dist/css/bootstrap.css">
    <script src="jquery-3.2.1.js"></script>
    <script src="bootstrap-4.4.1-dist/js/bootstrap.js"></script>
    <script src="layer/layer.js"></script>
    <style>
        .login{text-align: right;margin-bottom: 20px;}
        .img{position:relative;}
        .row img{width:100%;}
        .img .row{position:absolute; bottom:0;left:15px;background-color:rgba(0,0,0,0.5); width: 100%; color:white;
        font-size:8px;}
        p{margin:10px 0 !important;}
    </style>
</head>
<body>
<div class="container">
    <h1 class="text-center">我最爱的车辆投票</h1>
    <p class="login">
        <a href="javascript:open('login.php','用戶登录')">登录</a>
        <a href="javascript:open('singup.php','用戶注册')">注册</a>
    </p>
    <div class="row">
        <?php
            include_once 'conn.php';
            $sql = 'select * from carinfo order by id desc';
            $result = mysqli_query($conn,$sql);
            while($info = mysqli_fetch_array($result)){
        ?>
        <div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
            <div class="img">
                <a href="vote.php?id=<?php echo $info['id']?>">
                    <img src="img/<?php echo $info['carPic'];?>">
                </a>
                <div class="row">
                    <div class="col-xs-12 col-sm-8 col-md-6">
                        <p class="text-center">
                            <?php echo $info['carName'];?>
                        </p>

                    </div>
                    <div class="col-xs-12 col-sm-4 col-md-6">
                        <p class="text-center">当前的票数:
                            <?php echo $info['carNum'];?>
                        </p>

                    </div>
                </div>
            </div>
            <p>
                <?php echo $info['carDesc'];?>
            </p>
        </div>
        <?php }?>


</div>


</div>
<script>
 function open(url,title) {
     layer.open({
         type: 2,
         title:title,
         area: ['700px', '450px'],
         fixed: false, //不固定
         maxmin: true,
         content: url
     });
 }
</script>
</body>
</html>